package saucaca.Adapter;

import java.util.ArrayList;
import java.util.Map;

import lemon.kenhnhacvn.BaseActivity;
import lemon.kenhnhacvn.R;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.TextView;

public class PlaylistOfflineAdapter extends BaseAdapter {
	Context context;
	private ArrayList<Map<String, Object>> list;

	public PlaylistOfflineAdapter(Context context ) {
		this.context = context;
		this.list = BaseActivity.playListMusicMap;
	}
	public ArrayList<Map<String, Object>> getlist(){
		return list;
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public String getItem(int position) {
		return list.get(position).get(BaseActivity.Key_Title).toString();
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@SuppressLint({ "NewApi", "ViewHolder" })
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = LayoutInflater.from(context);
		convertView = inflater.inflate(R.layout.item_playlist, null);
		TextView playlistName = (TextView) convertView.findViewById(R.id.song_title);
		TextView playlistTotalSong = (TextView) convertView.findViewById(R.id.song_artist);
		ImageButton popup_menu = (ImageButton) convertView.findViewById(R.id.playlist_popup_menu);
		popup_menu.setVisibility(View.GONE);
		final String title = list.get(position).get(BaseActivity.Key_Title).toString();
		String artist = list.get(position).get(BaseActivity.Key_Artist).toString();
		playlistName.setText(title);
		playlistTotalSong.setText(artist);
		return convertView;
	}

}